package hu;

import java.util.*;

public class hu_qu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nums = sc.nextLine().split(" ");
        List<int[]> ans = new LinkedList<>();
        for (int i = 0; i < nums.length; i += 2) {
            int a = Integer.parseInt(nums[i]);
            int b = Integer.parseInt(nums[i + 1]);
            for (int j = i + 2; j < nums.length; j += 2) {
                int c = Integer.parseInt(nums[j]);
                int d = Integer.parseInt(nums[j + 1]);
                if(b < c)
                    continue;
                int[] f = new int[2];
                f[0] = Math.max(a, c);
                f[1] = Math.min(b, d);
                ans.add(f);
            }
        }
        ans.sort((a, b) -> {
            if (a[0] == b[0])
                return a[1] - b[1];
            return a[0] - b[0];
        });
        int[][] result = new int[ans.size()][2];
        int index = -1;
        for (int i = 0; i < ans.size(); i++) {
            if(index == -1 || result[index][1] < ans.get(i)[0])
                result[++index] = ans.get(i);
            else {
                result[index][1] = Math.max(result[index][1], ans.get(i)[1]);
            }
        }
        for (int i = 0; i <= index; i++) {
            System.out.print(result[i][0] + " ");
            System.out.print(result[i][1] + " ");
        }
    }
}
